
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/11/28
  Time: 18:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品列表</title>
    <link rel="stylesheet" href="/javaWeb01/css/product.css">
    <%--<script typet="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>--%>
</head>
<body>
 <%--<%--%>
     <%--User userAccount =(User) session.getAttribute("userAccount");--%>
      <%--if (userAccount==null){--%>
     <%--%>--%>
             <%--<a href="<%=request.getContextPath()%>/html/login.jsp"> 登录|</a>--%>
             <%--<a href="<%=request.getContextPath()%>/html/register.html"> 注册</a>--%>
     <%--<%--%>
      <%--}else {--%>
    <%--%>--%>
       <%--<div>欢迎<%= userAccount.getNickName()%> 进入书城 <a href="<%=userAccount.getId()%>">购物车</a></div>--%>
 <%--<a href="<%=request.getContextPath()%>/js/Logout.jsp">退出</a>--%>
    <%--<%--%>
      <%--}--%>
 <%--%>--%>
<c:choose>
    <c:when test="${ empty sessionScope.userAccount}">
        <a href="${pageContext.request.contextPath}/html/login.jsp"> 登录|</a>
        <a href="${pageContext.request.contextPath}/html/register.html"> 注册</a>
    </c:when>
    <c:otherwise>
        <div>欢迎${sessionScope.userAccount.nickName} 进入书城
            <a href="${pageContext.request.contextPath}/bookInfo?methodName=queryMyCart&uid=${sessionScope.userAccount.id}">购物车</a>
        </div>
        <a href="${pageContext.request.contextPath}/js/Logout.jsp">退出</a>
    </c:otherwise>
</c:choose>
<%--<%--%>
<%--//     List<Product> bookList =(List<Product>) request.getAttribute("bookList");--%>
     <%--Page<Product> bookListByPage =(Page<Product>) request.getAttribute("bookListByPage");--%>
     <%--int count=0;--%>
     <%--for (Product product:bookListByPage.getPageCotent()){--%>
<%--//         System.out.println(product);--%>
<%--//         for (Product product:bookList){--%>
 <%--%>--%>

 <%--<div class="border" style="float: left; <%if (count%3==0){%> clear:left;<%}%>">--%>
     <%--<div class="bgImg" style=" background-image: url('/javaWeb01<%=product.getProductImgurl()%>') "></div>--%>
     <%--<div class="wenzi">--%>
         <%--<span>作者：<span class="span "><%=product.getAuthor()%></span></span>--%>
         <%--<span>价格：<span class="span "><%=product.getPrice()%></span></span>--%>
     <%--</div>--%>
     <%--&lt;%&ndash;<div id="buy">&ndash;%&gt;--%>
         <%--&lt;%&ndash;<form action="" id="buyN">&ndash;%&gt;--%>
             <%--&lt;%&ndash;<input type="text" id="number" name="buyNumber" placeholder="请输入购买数量">&ndash;%&gt;--%>
             <%--&lt;%&ndash;<input type="button" name="car" id="shopCar" value="加入购物车" />&ndash;%&gt;--%>
         <%--&lt;%&ndash;</form>&ndash;%&gt;--%>
     <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
 <%--</div>--%>
 <%--<%--%>
         <%--count++;--%>
     <%--}--%>
 <%--%>--%>
 <c:forEach items="${bookListByPage.pageCotent}" var="pageList" varStatus="s">
         <div class="border"  id="${pageList.id}" style="float: left; <c:if test="${s.index%3==0}"> clear:left</c:if> ;">
             <div class="bgImg" style=" background-image: url('/javaWeb01/${pageList.productImgurl}') "></div>
             <div class="wenzi">
                 <span>作者：<span class="span ">${pageList.author}</span></span>
                 <span>价格：<span class="span ">${pageList.price}</span></span>
             </div>
         </div>

 </c:forEach>

 <script type="text/javaScript">
     window.onload=function () {
         var productInfo=document.querySelectorAll(".border");
         for (var i=0;i<productInfo.length;i++) {
             productInfo[i].onclick=function () {
                 window.location.href="${pageContext.request.contextPath}/bookInfo?methodName=getBookByProductId&productId="+this.id;
             }
         }
     }
 </script>
 <div id="page">
 <c:if test="${bookListByPage.currentPageCount>1 }">
         <a href="http://localhost/javaWeb01/bookServlet?methodName=getBookPageList">首页</a>
         <a href="http://localhost/javaWeb01/bookServlet?methodName=getBookPageList&CurrentPageCount=${bookListByPage.currentPageCount-1}">上一页</a>
 </c:if>
 <c:if test="${bookListByPage.currentPageCount<bookListByPage.totalPageCount}">
         <a href="http://localhost/javaWeb01/bookServlet?methodName=getBookPageList&CurrentPageCount=${bookListByPage.currentPageCount+1}">下一页</a>
         <a href="http://localhost/javaWeb01/bookServlet?methodName=getBookPageList&CurrentPageCount=${bookListByPage.totalPageCount}">末页</a></div>
 </c:if>

</body>
</html>
